<?php
 
load_control('datatable');

class action_set extends datatable
{
	var $count;
	
	function action_set($id, $user_id, $link_id=0, $return_zero=true, $form_name='0', $return_to='')
	{
		global $GO_CONFIG, $GO_SECURITY, $GO_MODULES, $GO_LANGUAGE, $GO_THEME, $GO_LINKS;
		
		$this->datatable($id, false, $form_name);
		$this->set_attribute('style','width:300px;margin-bottom:20px;margin-top:0px;');
		$return_to = !empty($return_to) ? $return_to : $_SERVER['PHP_SELF'];
		
		//require($GO_LANGUAGE->get_language_file('executor'));

		//require_once($GO_MODULES->modules['executor']['class_path']."executor.class.inc");
		//$executor = new executor();

		if($this->task == 'delete')
		{
			foreach($this->selected as $delete_executor_id)
			{
				$delete_executor_id =str_replace('4:', '', $delete_executor_id);
				$executor->delete_message($delete_executor_id);
			}
		}elseif($this->task=='unlink') // 删除短消息附带的 链接， 也就是附属文件
		{
			global $GO_LINKS;
			
			foreach($this->selected as $executor_id)
			{
				$executor_id =str_replace('4:', '', $executor_id);
				if($executor = $executor->get_message($executor_id))
				{
					$GO_LINKS->delete_link($link_id, $executor['link_id']);
				}
			}
		}
		
		$links = $link_id > 0 ? $GO_LINKS->get_links($link_id, 4) : false;
		// 错误回馈
		if (isset($feedback))
		{
			$p = new html_element('p', $feedback);
			$p->set_attribute('class','Error');
			$this->add_html_element($p);
		}
		
		$select = new select('sel_type');
		$arr_text = array('输入数据','审批','角色指派','通知');
		$arr_value = array('1','2','3','4');
		$select->add_arrays($arr_value, $arr_text);

		$this->add_outerhtml_element($select);
		// 文档单元格
		$this->add_column(new table_heading('任务编号', 'task_id'));
		// 字段单元格
		$this->add_column(new table_heading('显示内容', 'task_id'));
		// 操作单元格
		$this->add_column(new table_heading('操作', 'task_id'));
		$th = new table_heading('&nbsp;');
		//$this->add_column($th);
		// 获得短消息总数
/*	$this->count = $notes->get_notes($user_id, 
		$links, 
		$this->sort_index, 
		$this->sql_sort_order, 
		$this->start, 
		$this->offset);
		// 设置分页
		$this->set_pagination($this->count);*/ $this->count = 1;
		// 遍历当前用户短消息内容
		if($this->count > 0)
		{
			//while($notes->next_record())
			//{
				$row = new table_row('4:'.$id);
				// 双击表格某一行，显示该行的信息  【该行可删除】
			/*	$row->set_attribute('ondblclick', 
							"javascript:window.location.href='".					
							$GO_MODULES->modules['message']['url'].'message.php?message_id='.$message->f('id').
							'&return_to='.urlencode($return_to)."';");	
			*/	
				$doc_id = array('1');			
				$doc_name = array('部门审批');
				$field_id = array('2');
				$field_name = array('字段名');
				$operation = '删除';
				
				$sel_doc_name = new select('sel_doc_name');
				$sel_doc_name->add_arrays($doc_id,$doc_name);
				$sel_field_name = new select('sel_field_name');
				$sel_field_name->add_arrays($field_id,$field_name);

				// 文档单元格
				$cell = new table_cell();
				$cell->set_attribute('sytle','width:100 px');
				$cell->add_html_element($sel_doc_name);
				$row->add_cell($cell);
				// 字段单元格
				$cell = new table_cell();
				$cell->set_attribute('style','width:400 px');
				$cell->add_html_element($sel_field_name);
				$row->add_cell($cell);
				// 操作单元格
				$cell = new table_cell($operation);
				$cell->set_attribute('style','width:100 px');
				$row->add_cell($cell);				
				
				// 将以上单元格加入该行			
				$this->add_row($row);	
			//}		
		}else
		{
			if($return_zero)
			{
				$row = new table_row();
				$cell = new table_cell($no_no_message);
				$cell->set_attribute('colspan','99');
				$row->add_cell($cell);
				$this->add_row($row);
			}else
			{
				$this->innerHTML = '';
				return false;
			}
		}
	}
}
